//! 提供了开发工具宏
//!
//! 用于快速创建 sgs_core::pkg::Pattern 类型
//!

/// 生成 Pattern 的声明宏
#[macro_export]
macro_rules! create_pattern {

    ($n:expr) => {{
        Into::<$crate::pkg::Pattern>::into (match $n {
            2 => $crate::utils::pattern::PatternOption::Player2,
            3 => $crate::utils::pattern::PatternOption::Player3,
            4 => $crate::utils::pattern::PatternOption::Player4,
            5 => $crate::utils::pattern::PatternOption::Player5,
            6 => $crate::utils::pattern::PatternOption::Player6,
            7 => $crate::utils::pattern::PatternOption::Player7,
            8 => $crate::utils::pattern::PatternOption::Player8,
            9 => $crate::utils::pattern::PatternOption::Player9,
            10 => $crate::utils::pattern::PatternOption::Player10,
            11 => $crate::utils::pattern::PatternOption::Player11,
            12 => $crate::utils::pattern::PatternOption::Player12,
            _ => $crate::utils::pattern::PatternOption::Unknown,
        })
    }};

    (@range $range:expr) => {{
        $crate::utils::pattern::PatternOption::from_range($range)
    }};

    ($start:expr => $end:expr) => {{
        create_pattern!(@range $start..$end)
    }};

    ($start:expr =>  +$end:expr) => {{
        create_pattern!(@range $start..($end+1))
    }};


    ($($n:expr),+ $(,)?) => {{
        vec![$(create_pattern!($n)),+]
    }};

}

#[cfg(test)]
mod test {

    #[test]
    fn test_create_pattern_macro() {
        let p = create_pattern!(6);

        println!("{:?}", p)
    }
}
